package com.group.elmboot.controller;

import java.util.List;

import com.group.elmboot.po.Orders;
import com.group.elmboot.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RefreshScope//开启动态刷新
@RestController
@RequestMapping("/OrdersController")
public class OrdersController {

	@Autowired
	private OrdersService ordersService;
	
	@RequestMapping("/createOrders")
	public int createOrders(Orders orders) throws Exception{
		return ordersService.createOrders(orders);
	}
	
	@RequestMapping("/getOrdersById")
	public Orders getOrdersById(Orders orders) throws Exception{
		return ordersService.getOrdersById(orders.getOrderId());
	}
	
	@RequestMapping("/listOrdersByUserId")
	public List<Orders> listOrdersByUserId(Orders orders) throws Exception{
		return ordersService.listOrdersByUserId(orders.getUserId());
	}
	
	@RequestMapping("/payOrders/{redPacket}")
	public int payOrders(Orders orders, @PathVariable String redPacket) throws Exception{
		return ordersService.payOrders(orders,redPacket);
	}
	
	@RequestMapping("/listOrdersByBusinessId")
	public List<Orders> listOrdersByBusinessId(Orders orders) throws Exception{
		return ordersService.listOrdersByBusinessId(orders.getBusinessId());
	}
}
